package com.juzipi.demo.job;

import com.juzipi.demo.timing.MailJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author juzipi
 * @Date 2021/7/30 10:38
 * @Info
 */
@Configuration
public class MailJobDetail {


    @Bean
    public JobDetail sampleJobDetail(){
        return JobBuilder.newJob(MailJob.class).withIdentity("mailJob").usingJobData("name", "Quartz").storeDurably().build();
    }


    @Bean
    public Trigger sampleJobTrigger(){
        SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(60).repeatForever();
        return TriggerBuilder.newTrigger().forJob(sampleJobDetail()).withIdentity("mailTrigger").withSchedule(simpleScheduleBuilder).build();
    }

}
